package com.example.demo.day0303;

import java.lang.reflect.*;

import java.lang.reflect.InvocationHandler;

public class DemoProxy implements InvocationHandler {

    Object obj;//被代理的对象

    public DemoProxy(Object obj){
        this.obj = obj;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        System.out.println(method + " start running");
        Object resulet = method.invoke(this.obj,args);//执行的是指定代理对象的指定的方法
        System.out.println(method + " is finished");
        return resulet;
    }
}
